﻿using FreeSql;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using TK.FreeSqlExtension.Demo.Entity;

namespace TK.FreeSqlExtension.Demo.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {
        private readonly ILogger<WeatherForecastController> _logger;
        private readonly IFreeSql _freeSql;
        private readonly BaseRepository<SysUser> _userRepository;

        public WeatherForecastController(
            ILogger<WeatherForecastController> logger,
            IFreeSqlFactory freeSqlFactory,
            BaseRepository<SysUser> userRepository)
        {
            _logger = logger;
            _freeSql = freeSqlFactory.GetFreeSql();
            _userRepository = userRepository;
        }

        [HttpGet]
        public IEnumerable<SysUser> Get()
        {
            var list = _userRepository.Select.ToList();
            //var list1 = _freeSql.Select<SysUser>().ToList();

            return list;
        }
    }
}
